package Operations;

import Book.book;
import Book.bookList;

import java.util.Scanner;
//定义归还书籍操作这个类重写实现接口中的work抽象方法
public class ReturnOperation implements Ioperations {
    @Override
    public void work(bookList bookList) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要归还书籍的名字");
        String name = scanner.nextLine();
        int i = 0;
        //用遍历的方式查询书架中是否存在输入的书名
        for (; i < bookList.getUseMount(); i++) {
            //用bookList已写的方法获取下标为i的书对象
            book book = bookList.getBooks(i);
            if (book.getName().equals(name)) {
                //将该书的借阅状态设置为false
                bookList.getBooks(i).setBorrowed(false);
                System.out.println("当前图书状态"+book);
                System.out.println("归还书籍成功");
                return;
            }
        }
    }
}
